package com.ato.MyCollection;

import java.util.*;

/**
 * @author wangjing
 * @create 2021--11--29--22:17
 */
public class CollectionsUtilsTest {
    public static void main(String[] args) {
//        re
        ArrayList arrayList = new ArrayList();
        arrayList.add(110);
        arrayList.add(310);
        arrayList.add(210);
        arrayList.add(210);
        arrayList.add(210);
        System.out.println(arrayList);
//        反转List
        Collections.reverse(arrayList);
        System.out.println(arrayList);
//        随机排序
        Collections.shuffle(arrayList);
        System.out.println(arrayList);
//        自然排序
        Collections.sort(arrayList);
        System.out.println(arrayList);
//        交换list里索引I和索引J的位置
        Collections.swap(arrayList, 1, 2);
        System.out.println(arrayList);
        HashMap<Integer, Integer> hashMap = new HashMap<>();
        hashMap.put(1, 2);
        hashMap.put(6, 7);
//        返回最大的一个
        Comparable max = Collections.max(arrayList);
        System.out.println(max);

        int frequency = Collections.frequency(arrayList, 2100);
        System.out.println("frequency 出现最大次数 " + frequency);
//复制: 注意 需要定义好dest的长度
        List dest = Arrays.asList(new Object[arrayList.size()]);
        Collections.copy(dest, arrayList);
        System.out.println(dest);
//replaceAll(List arrayList,Object oldValue, Object newValue);
        boolean b = Collections.replaceAll(arrayList, 110, 100);
        System.out.println(arrayList);
        List list = Collections.synchronizedList(arrayList);


    }
}
